import 'package:flutter/material.dart';
import 'package:jiaju_flutter/routes.dart';

class RegistorPage extends StatefulWidget {
  RegistorPage({Key key}) : super(key: key);

  @override
  _RegistorPageState createState() => _RegistorPageState();
}

class _RegistorPageState extends State<RegistorPage> {
  _buildInputWidget(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 30),
      child: Column(
        children: [
          TextField(
            decoration: InputDecoration(labelText: "用户名"),
          ),
          Padding(
            padding: EdgeInsets.only(top: 10),
            child: TextField(
              decoration: InputDecoration(labelText: "密码"),
            ),
          ),
          Padding(
            padding: EdgeInsets.only(top: 10),
            child: TextField(
              decoration: InputDecoration(labelText: "确认密码"),
            ),
          ),
        ],
      ),
    );
  }

  _buildRegistorBtnWidget(BuildContext context) {
    var width = MediaQuery.of(context).size.width;
    return Container(
      margin: EdgeInsets.only(top: 30),
      child: ElevatedButton(
        style: ButtonStyle(
            backgroundColor: MaterialStateProperty.all(Colors.green)),
        child: Container(
          alignment: Alignment.center,
          width: width,
          child: Text("注册"),
        ),
        onPressed: () => {},
      ),
    );
  }

  _buildLoginTextWidget(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 20),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Padding(
            padding: EdgeInsets.only(right: 20),
            child: Text("已有账号"),
          ),
          TextButton(
            child: Text(
              "去登录~~",
              style: TextStyle(color: Colors.green),
            ),
            onPressed: () =>
                Navigator.pushReplacementNamed(context, Routes.login),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    var width = MediaQuery.of(context).size.width;
    return Scaffold(
      appBar: AppBar(
        title: Text("注册"),
      ),
      body: Container(
        padding: EdgeInsets.only(left: 30, right: 30),
        width: width,
        child: Column(
          children: [
            _buildInputWidget(context),
            _buildRegistorBtnWidget(context),
            _buildLoginTextWidget(context),
          ],
        ),
      ),
    );
  }
}
